package com.example.controller.other;

import com.example.common.Result;

import com.example.model.entity.other.HelpDetail;
import com.example.service.other.HelpDetailService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 帮助中心详细表前端操作接口
 **/
@RestController
@RequestMapping("/helpDetail")
@Api(tags = "帮助中心详细接口")
public class HelpDetailController {

    @Resource
    private HelpDetailService helpDetailService;

    /**
     * 新增
     */
    @ApiOperation(value = "新增帮助中心详细")
    @PostMapping("/add")
    public Result add(@RequestBody HelpDetail helpDetail) {
        helpDetailService.add(helpDetail);
        return Result.success();
    }

    /**
     * 删除
     */
    @ApiOperation(value = "删除帮助中心详细")
    @DeleteMapping("/delete/{id}")
    public Result deleteById(@PathVariable Integer id) {
        helpDetailService.deleteById(id);
        return Result.success();
    }

    /**
     * 批量删除
     */
    @ApiOperation(value = "批量删除帮助中心详细")
    @DeleteMapping("/delete/batch")
    public Result deleteBatch(@RequestBody List<Integer> ids) {
        helpDetailService.deleteBatch(ids);
        return Result.success();
    }

    /**
     * 修改
     */
    @ApiOperation(value = "修改帮助中心详细")
    @PutMapping("/update")
    public Result updateById(@RequestBody HelpDetail helpDetail) {
        helpDetailService.updateById(helpDetail);
        return Result.success();
    }
    /**
     * 根据ID查询
     */
    @GetMapping("/selectByHelpId")
    public Result selectByHelpId(@RequestParam Integer helpId) {
        List<HelpDetail> helpDetail = helpDetailService.selectByHelpId(helpId);
        return Result.success(helpDetail);
    }
    /**
     * 根据ID查询
     */
    @ApiOperation(value = "根据ID帮助中心详细")
    @GetMapping("/selectById/{id}")
    public Result selectById(@PathVariable Integer id) {
        HelpDetail helpDetail = helpDetailService.selectById(id);
        return Result.success(helpDetail);
    }

    /**
     * 查询所有
     */
    @ApiOperation(value = "查询所有帮助中心详细")
    @GetMapping("/selectAll")
    public Result selectAll(HelpDetail helpDetail) {
        List<HelpDetail> list = helpDetailService.selectAll(helpDetail);
        return Result.success(list);
    }

    /**
     * 分页查询
     */
    @ApiOperation(value = "分页查询帮助中心详细")
    @GetMapping("/selectPage")
    public Result selectPage(HelpDetail helpDetail,
                             @RequestParam(defaultValue = "1") Integer pageNum,
                             @RequestParam(defaultValue = "10") Integer pageSize) {
        PageInfo<HelpDetail> page = helpDetailService.selectPage(helpDetail, pageNum, pageSize);
        return Result.success(page);
    }

}
